import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/pages/common/myWords.dart';
import 'package:ichinesereader/pages/individual/myFavoriteBooks.dart';
import 'package:ichinesereader/routes/routePages.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/layouts/appdrawerIndividual.dart';
import 'package:ichinesereader/widgets/layouts/customAppBar.dart';
import 'package:ichinesereader/widgets/sidebars/individualSidebar.dart';
import '../../themes/appTheme.dart';
import '../../themes/pageStyles.dart';

class MyFavoritesPageForIndividual extends StatelessWidget {
  static const String routeName = '/individual/myfavorites';

  @override
  Widget build(BuildContext context) {
    Log.debug('build individual myfavorites');
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    final isBigScreen =
        MediaQuery.of(context).size.width > Constants.DefinedScreenBigSize;
    int _selectedSidebarItem = RoutePages.individualPageItems
        .indexWhere((page) => page.route == Get.currentRoute);
    final PageStyles _pageStyles = PageStyles();

    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: isSmallScreen ? CustomAppBar(title: 'My Favorites'.tr) : null,
          drawer: isSmallScreen ? IndividualAppDrawer() : null,
          body: Container(
            decoration: _pageStyles.pageBoxDecoration(),
            child: Row(
              children: [
                Visibility(
                    visible: !isSmallScreen,
                    child: Container(
                        child: IndividualSidebarX(
                            selectedIndex: _selectedSidebarItem,
                            isBigScreen: isBigScreen))),
                Expanded(
                  flex: 10,
                  child: Container(
                    margin: _pageStyles.mainContainerPageEdgeInsets(),
                    child: Column(
                      children: [
                        Expanded(
                          flex: 1,
                          child: Stack(
                            alignment: Alignment.center,
                            children: [
                              Container(
                                padding: EdgeInsets.symmetric(vertical: 12.0),
                                decoration: BoxDecoration(
                                  color: Get.isDarkMode
                                      ? AppTheme.colors.darkTheme2
                                      : Colors.black.withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(3.0),
                                ),
                              ),
                              Container(
                                child: _pageStyles.buildTabBar([
                                  'My Books',
                                  'My Words',
                                ]),
                              ),
                            ],
                          ),
                        ),
                        Expanded(
                          flex: 11,
                          child: Padding(
                            padding: const EdgeInsets.only(right: 6.0),
                            child: Container(
                              child: TabBarView(
                                children: [
                                  MyFavoriteBooksForIndividual(),
                                  MyKnowledgeWordsPage(
                                    folderId: '',
                                    level: '',
                                    isMainFolder: true,
                                  )
                                ],
                              ),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
